package top.zackyoung.springboot.controller

import com.alibaba.fastjson.{JSON, JSONObject}
import org.springframework.web.bind.annotation.{PathVariable, RequestMapping, RestController}
import top.zackyoung.springboot.entity.ScalaUser
import top.zackyoung.springboot.service.ScalaUserService

import javax.annotation.Resource

@RestController
@RequestMapping(Array {
  "/scala"
})
class ScalaController {
  @Resource
  var scalaUserService: ScalaUserService = _


  @RequestMapping(path = Array("/test/{id}"))
  def test(@PathVariable("id") id: Integer): String = {
    s"scala id is：$id"
  }

  @RequestMapping(path = Array("/get/{id}"))
  def getId(@PathVariable id: Long): ScalaUser = {
      scalaUserService.getById(id).get()
  }
  @RequestMapping(path = Array("/get2/{id}"))
  def get2Id(@PathVariable id: Long): ScalaUser = {
      scalaUserService.getByIdMP(id).get()
  }
}
